const Config = require('./../config')
const Mongoose = require('mongoose');
const db = Config.mongodb();

Mongoose.connect('mongodb://' + db.connect + '/' +  db.name, { useNewUrlParser: true });
// 连接失败
Mongoose.connection.on("error", function(err){
    console.error("数据库链接失败:"+ err);
});
// 连接成功
Mongoose.connection.on("open", function(){
    console.log("数据库链接成功");
});
// 断开数据库
Mongoose.connection.on("disconnected", function(){
    console.log("数据库断开");
})
module.exports = Mongoose;